import { defHttp } from '@/utils/http/axios';
import {
  bookListParams,
  listParams,
  detailParams,
  saveParams,
  userListParams,
  setBooksParams,
  setLevelsParams,
} from './model/clazzModel';
import { BasicListResult, BasicDataResult } from '../model/baseModel';

import { ErrorMessageMode } from '#/axios';
import { d } from 'vite/dist/node/types.d-aGj9QkWt';

enum Api {
  //Login = '/login',
  list = '/hl/sys/clazz/list',
  save = '/hl/sys/clazz/save',
  delete = '/hl/sys/clazz/delete',
  detail = '/hl/sys/clazz/detail',
  getBooks = '/hl/sys/clazz/getBooks',
  getLevels = '/hl/sys/clazz/getLevels',
  getUsers = '/hl/sys/clazz/getUsers',
  setBooks = '/hl/sys/clazz/setBooks',
  setLevels = '/hl/sys/clazz/setLevels',
  clazzSelects = '/hl/sys/clazz/clazzSelects',
  bookClazzNameList = '/hl/sys/clazz/bookClazzNameList',
}

/**
 * @description: user login api
 */
export function listApi(params: listParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicListResult>(
    {
      url: Api.list,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function saveApi(params: saveParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.save,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function detailApi(params: detailParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.detail,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function deleteApi(params: detailParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.delete,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function getBooksApi(params: bookListParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.getBooks,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function bookClazzNameListApi(params: bookListParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.bookClazzNameList,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function getUsersApi(params: userListParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.getUsers,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
export function setBooksApi(params: setBooksParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.setBooks,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
export function setLevelApi(params: setLevelsParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.setLevels,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function getLevelsApi(params: detailParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.getLevels,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function clazzSelectsApi(params: null, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicDataResult>(
    {
      url: Api.clazzSelects,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
